#ifndef __LOD_SELECTION_H__
#define __LOD_SELECTION_H__

//view frustum culling and LOD selection class
//#include "../glh_linear.h"

//using namespace glh;

class ShaderObject;
class Camera;

struct sVBOLod;
/*
struct _plane
{
	vec3f normal, point;
	float d;
};

typedef struct _plane sPlane;
*/
class cLODSelection
{
public:
	enum
	{
		VBO_CULLED,
		VBO_LOD0,
		VBO_LOD1,
		VBO_LOD2
	};

	

	cLODSelection ();
	~cLODSelection();

	void init (int numAgentsWidth_, int numAgentsHeight_, int _numLODs);
	void initForCrowds (int characterPerGroup, int _numLODs);
	void VFC_LOD_Assignation (unsigned int target, unsigned int posID, Camera *cam);
	void LODSorting(struct sVBOLod *vboLOD);
	void runSelection(unsigned int target, unsigned int posID, struct sVBOLod *vboLOD, Camera *cam);// type can be Texture or Vertex Buffer
	void runSelection(unsigned int posVFCwithLOD, struct sVBOLod *vboLOD, unsigned int primitivesWritten, Camera *cam, int animationId); // crowd Version
	void draw(struct sVBOLod *vboLOD, float *color);

	int numAgentsWidth, numAgentsHeight;

private:
	void initTexCoords(unsigned int target);
	int numElements;
	int numLODs;
	unsigned int *posVBOLODs, query;
	unsigned int *posTexBufferId;
	
	unsigned int texCoords;

	ShaderObject *lodSelection, *drawVBOTextureBuffer, *VFCLodAssigmentTex;
	unsigned int primitivesWritten[5];
	/*
	ShaderObject *VFCLodAssigment, *VFCLodAssigmentTex, *lodSelection;
	ShaderObject *drawVBO, *drawVBOTextureBuffer;
	*/
};

#endif
